#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main()
{
	int y = 0;
	int m = 0;
	int d = 0;
	int count = 0;
	scanf("%d/%d/%d", &y, &m, &d);

	if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
	{
		if (m == 1)
		{
			count = d;
		}
		if (m == 2)
		{
			count = 31 + d;
		}
		if ((m-1) % 2 == 1 &&m!=2)
		{
			count = 31 * (m / 2) + 30 * ((m - 2) / 2)-1+d;
		}
		if ((m-1) % 2 == 0 && (m-1) != 1)
		{
			count = 31 * (m-1) / 2 + 30 * (m-1) / 2-1+d;
		}
	}
	else
	{
		if (m == 1)
		{
			count = d;
		}
		if ((m - 1) % 2 == 1)
		{
			count = 31 * (m / 2) + 30 * ((m - 2) / 2) - 2 + d;
		}
		if ((m - 1) % 2 == 0 && (m - 1) != 1)
		{
			count = 31 * (m - 1) / 2 + 30 * (m - 1) / 2 - 2 + d;
		}
	}
	printf("%d", count);
}